//
//  PopupManager.m
//  DabaiInsurance
//
//  Created by menchao on 16/7/29.
//  Copyright © 2016年 menchao. All rights reserved.
//

#import "PopupManager.h"
#import "MBProgressHUD.h"

@implementation PopupManager


+ (void)showTipsWithOnlyText:(NSString *)text inView:(UIView *)inView
{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:inView animated:YES];
    // Configure for text only and offset down
    hud.mode = MBProgressHUDModeText;
    hud.opacity = 0.5;
    hud.detailsLabelFont = [UIFont boldSystemFontOfSize:15.0];
    hud.detailsLabelText = text;
    hud.removeFromSuperViewOnHide = YES;
    [hud hide:YES afterDelay:1.5];
}


+ (void)showMessage:(NSString *)message
{
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [self showTipsWithOnlyText:message inView:window];
}

+ (void)showMessageWithLoading:(NSString *)message{
    
     UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [self showMessage:message toView:window];
}


+ (MBProgressHUD *)showMessage:(NSString *)message toView:(UIView *)view {
    // 快速显示一个提示信息
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.labelText = message;
     hud.detailsLabelFont = [UIFont boldSystemFontOfSize:16.0];
    // 隐藏时候从父控件中移除
    hud.removeFromSuperViewOnHide = YES;
    // YES代表需要蒙版效果
    //hud.dimBackground = YES;
    return hud;
}

/**
 *  手动关闭MBProgressHUD
 */
+ (void)hideHUD
{
    [self hideHUDForView:nil];
}


+ (void)hideHUDForView:(UIView *)view
{
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [MBProgressHUD hideHUDForView:window animated:YES];
}

@end
